<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>影院后台管理系统 - 登录</title>
    <meta name="keywords" content="perfect-ssm">
    <meta name="description" content="perfect-ssm">
    <link
            href="static/css/bootstrap.min14ed.css"
            rel="stylesheet">
    <link
            href="static/css/font-awesome.min93e3.css"
            rel="stylesheet">
    <link href="static/css/animate.min.css"
          rel="stylesheet">
    <link href="static/css/style.min862f.css"
          rel="stylesheet">
    <script type="text/javascript"
            src="static/js/jquery-2.1.4.js"></script>
    <script type="text/javascript"
            src="static/js/bootstrap-3.3.4.js"></script>
</head>
<script src="component/js/common.js"></script>
</head>
<body class="gray-bg">
<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name">MM</h1>
        </div>
        <h3>欢迎使用 影院后台管理系统</h3>

        <form class="m-t" role="form" id="userlogin" method="post"
              name="userlogin" onsubmit="return false" action="##">
            <div class="form-group">
                <input type="email" class="form-control" placeholder="用户名"
                       name="username" id="username">

            </div>
            <div class="form-group">
                <input type="password" class="form-control" placeholder="密码"
                       name="password" id="password"
                       onkeydown="if(event.keyCode==13) login()">

            </div>
            <button type="button" class="btn btn-primary block full-width m-b"
                    onclick="login();">登 录</button>
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
    function login() {
        var username = $("#username").val();
        var password = $("#password").val();

        if (username == null || username == "") {
            alert("用户名不能为空！");
            return;
        }
        if (password == null || password == "") {
            alert("密码不能为空！");
            return;
        }
        $.ajax({
            type : "post",
            url : SERVER_URL+"/sysuser/login",
            data : $('#userlogin').serialize(),
            success : function(result) {
                if (result.code == 200) {
                    setCookie("manage_id", result.data.id);
                    setCookie("manage_username", result.data.username);
                    loginRedirect();
                } else {
                    alert(result.message);
                }
            },
            error : function() {
                alert("异常！");
            }
        });
    }

    function loginRedirect() {
        //window.location.href = "/index.html";
        getRootPath();
        window.location.href = manageurl+"/index.html"
    }
</script>
</html>
